package com.lxq.test2009.Main02;

import java.util.Scanner;

class Person{
    int tempx,tempy,t,maxStayTime;//maxStayTime存储最长逗留时间
    boolean passFlag,hasPassed;
    Scanner sc;

    public Person(int t, Scanner sc){
        this.t = t;
        maxStayTime = 0;
        this.sc = sc;
        passFlag = hasPassed = false;
    }

    public boolean pass(int x1,int y1,int x2,int y2){
        int tempStayTime=0;
        for (int i=0 ; i<t ; i++){
            tempx = sc.nextInt();
            tempy = sc.nextInt();
            if(tempx>=x1&&tempx<=x2&&tempy>=y1&&tempy<=y2){
                passFlag = true;
                tempStayTime++;

            }else{
                if(tempStayTime>maxStayTime) maxStayTime = tempStayTime;
                tempStayTime = 0;

            }

        }
        if(tempStayTime>maxStayTime) {
            maxStayTime = tempStayTime;
        }

        return passFlag;
    }

    public boolean stay(int k){

        return maxStayTime >= k;

    }
}

public class Main {

    public static void main(String[] args) {
        int n,k,t,x1,y1,x2,y2;//n:人数  k:逗留参考点数  t:参考点数   x,y:风险区定点
        int pass = 0,stay = 0;//经过和逗留人数
        Person person;

        Scanner sc = new Scanner(System.in);

        n=sc.nextInt();
        k=sc.nextInt();
        t=sc.nextInt();
        x1=sc.nextInt();
        y1=sc.nextInt();
        x2=sc.nextInt();
        y2=sc.nextInt();

        for (int i=0;i<n;i++){
            person = new Person(t,sc);
            if (person.pass(x1,y1,x2,y2)) pass++;
            if (person.stay(k)) stay++;
        }


        System.out.print(pass + "\n" + stay);
    }
}
